package com.huang.jwt;

import com.google.gson.JsonObject;
import com.huang.util.GsonUtils;
import com.nimbusds.jose.JWSObject;

import java.text.ParseException;

/**
 * @author han
 * @since 2022-01-17 15:09:41
 */
public class Jwt {

    public static void main(String[] args) throws ParseException {
        JWSObject jwsObject = JWSObject.parse("89903935-4ed8-4848-9bf5-3c55c097f667");
        String userStr = jwsObject.getPayload().toString();
        System.out.println(userStr);


        String str = "{\"phone\":\"15102760632\",\"user_name\":\"黄阿能\",\"scope\":[\"webapp\"],\"id\":\"10\",\"exp\":1642453554,\"authorities\":[\"admin-brother\",\"admin\",\"ordinary\"],\"jti\":\"f91fdf64-7140-49af-956b-155243a0c859\",\"client_id\":\"webapp\"}";
        JsonObject jsonObject = GsonUtils.string2Object(str);
        String authorities = jsonObject.getAsJsonArray("authorities").toString();
        System.out.println(authorities);
    }
}
